package com.tianhai.utils;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public static Result success(Object data) {
        return new Result(0, "操作成功", data);
    }

    public static Result error(Object data) {
        return new Result(2, "操作失败", data);
    }

    public static Result success(String msg, Object data) {
        return new Result(0, msg, data);
    }

    public static Result error(String msg, Object data) {
        return new Result(2, msg, data);
    }
}
